<?php

//传值赋值及引用赋值
$a = 123;
$b = $a; //传值赋值, 把a的值复制一份保存到b中, 修改一个变量的值并不影响另一个变量的值
$a = 456;
echo "a=$a, b=$b\n"; //a=456, b=123
$c =& $a; //引用赋值, 变量c就是a的别名，修改一个变量的值会影响另一个变量的值
$c = 789;
echo "a=$a, c=$c\n"; //a=789, c=789

$a2 = ['name' => '张三', 'age' => 18];
$b2 = $a2; //传值赋值
$b2['age'] = 20;
print_r($a2);
print_r($b2);
echo "-----------------\n";
$c2 =& $a2; //传引用
$c2['age'] = 30;
print_r($a2);
print_r($c2);



